Writes a number of characters to the STDIN stream of a previously run child process.
StdinWrite ( process_id[, string] )
Parameters
process_id | The process ID of a child process, as returned by a previous call to Run. |
string | String of characters to write. |
Return Value
Success: | Returns the number of characters written. |
Failure: | Sets @error to -1 if STDIN was not redirected for the process or other error. |
Remarks
StdinWrite writes to the console standard input stream for a child process, which is normally used by console applications to read input from the user i.e. from the keyboard. During the call to Run for the child process you wish to write to the STD I/O parameter must have included the value of $Stdin_Child for this function to work properly.
Related
StdoutRead, StderrRead, Run
Example
; Demonstrates the use of StdinWrite()
#include <Constants.au3>
$foo = Run("sort.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
; Write string to be sorted to child sort.exe's STDIN
StdinWrite($foo, "rat" & @CRLF & "cat" & @CRLF & "bat" & @CRLF)
; Calling with no 2nd arg closes stream
StdinWrite($foo)
; Read from child's STDOUT and show
MsgBox(0, "Debug", StdoutRead($foo))